package space.goldchen.mapstruct.mapper;

import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.Mappings;
import org.mapstruct.ReportingPolicy;
import space.goldchen.mapstruct.dto.PigDto;
import space.goldchen.mapstruct.entity.Pig;

/**
 * @author 2021
 * @create 2025-04-18 16:52
 */
@Mapper(componentModel = "spring",unmappedTargetPolicy = ReportingPolicy.IGNORE)
public interface PigDtoMapper extends BaseMapper<PigDto,Pig> {
    /**
     *  pig转为pigDto
     * @param pig
     * @return
     */
    @Mappings({
            // 属性名称一致时，可以省略
            @Mapping(source = "id", target = "id"),
            @Mapping(source = "name", target = "name"),
            @Mapping(source = "age", target = "age")
    })
    public PigDto toDto(Pig pig);

}
